package com.hdax.dm.controller;

import com.hdax.dm.common.vo.item.ItemListVo;
import com.hdax.dm.dto.CommonResponse;
import com.hdax.dm.dto.PageDto;
import com.hdax.dm.dto.item.FloorItemDto;
import com.hdax.dm.dto.item.IndexNavTypeDto;
import com.hdax.dm.dto.item.ItemListDto;
import com.hdax.dm.service.DmItemListService;
import com.hdax.dm.service.DmItemService;
import com.hdax.dm.service.DmItemTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.awt.geom.Area;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(path = "/list")
public class ItemListController {

    @Autowired
    private DmItemListService itemListService;
    @Autowired
    private DmItemTypeService typeService;
    @Autowired
    private DmItemService itemService;

    //查询城市
    @PostMapping(path = "/querycity")
    public CommonResponse<List<Area>> querycity(){
        return itemListService.querycity();
    }

    //根据一级查询二级分类信息
    @PostMapping(path = "/sortgoods")
    public CommonResponse<List<IndexNavTypeDto>> sortgoods(@RequestBody Map<String,Long> params){
        return typeService.sortgoods(params.get("parent"));
    }

    //商品检索vo/entity/itemconsumer
    @PostMapping(path = "/querygoodsinfos")
    public CommonResponse<PageDto<ItemListDto>> querygoodsinfos(@RequestBody ItemListVo itemListVo){
        return itemListService.querygoodsinfos(itemListVo);
    }

    //猜你喜欢
    @PostMapping(path = "/guesslike")
    public CommonResponse<List<FloorItemDto>> guesslike(@RequestBody Map<String,Long> params){
        return itemListService.guesslike(params.get("itemTypeId"));
    }
}
